package com.class05.fruit.servlets;

import com.class05.fruit.dao.FruitDAO;
import com.class05.fruit.dao.impl.FruitDAOImpl;
import com.class05.myssm.myspringmvc.ViewBaseServlet;
import com.class05.myssm.util.StringUtil;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/del.do")
public class DelServlet extends ViewBaseServlet {
   private FruitDAO fruitDAO=new FruitDAOImpl();

   @Override
   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      String fidStr = req.getParameter("fid");
      if (StringUtil.isNotEmpty(fidStr)){
         int fid=Integer.parseInt(fidStr);
         fruitDAO.delFruit(fid);
         resp.sendRedirect("index");
      }
   }
}
